package com.dindang.ddm.mvp.ui.adapter.custom;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dindang.ddm.R;
import com.dindang.ddm.mvp.model.entity.NewsList;

import java.util.List;

/**
 * Created by cxw on & 2018/9/4
 */
public class AutoPollAdapter extends RecyclerView.Adapter<AutoPollAdapter.BaseViewHolder> {
    private final Context mContext;
    private final List<NewsList.News> mData;

    public AutoPollAdapter(Context context, List<NewsList.News> list) {
        this.mContext = context;
        this.mData = list;
    }
    @Override
    public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_notice, parent, false);
        BaseViewHolder holder = new BaseViewHolder(view);
        return holder;
    }
    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        String data = mData.get(position % mData.size()).getTitle();
        holder.mTvNewTitle.setText(data);
    }
    @Override
    public int getItemCount() {
        return Integer.MAX_VALUE;
    }
    class BaseViewHolder extends RecyclerView.ViewHolder {
        TextView mTvNewTitle;
        public BaseViewHolder(View itemView) {
            super(itemView);
            mTvNewTitle = (TextView) itemView.findViewById(R.id.tv_new_title);
        }
    }
}
